﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class logout : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["sUserName"] != null)
        {
            Conn zconn = new Conn();
            string zdate = DateTime.Now.ToString();
            string zuserip = Request.UserHostAddress.ToString();
            string zsql1 = "insert into details (user_ip,jigou,role,username,username1,xtsj,detail) values ('" + zuserip + "','" + Session["sJigou"].ToString() + "','" + Session["sRole"].ToString() + "','" + Session["sUserName"].ToString() + "','" + Session["sUserName1"].ToString() + "','" + zdate + "','用户注销')";
            int noth = zconn.ExeSql(zsql1);
            zconn.Dispose();
        }

        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetAllowResponseInBrowserHistory(false);

        Dictionary<string, string> userList = Application.Get("GLOBAL_USER_LIST") as Dictionary<string, string>;
        if (userList != null)
        {
            if (userList.ContainsKey(Session.SessionID))
            {
                if (userList[Session.SessionID] != null)
                {
                    userList.Remove(Session.SessionID);
                    Application.Lock();
                    Application.Add("GLOBAL_USER_LIST", userList);
                    Application.UnLock();
                    Session.RemoveAll();
                }
            }
            else
            {
                Session.RemoveAll();
                FormsAuthentication.SignOut();
            }
        }
        else
        {
            Session.RemoveAll();
            FormsAuthentication.SignOut();
        }
    }
}
